//处理推荐作者逻辑
const db = require("../lib/db");
function authorsList(){
    return new Promise((resolve,reject)=>{
        let sql = "select * from author";
        db.querySql(sql).then(data=>{
            if(data.length==0){
                resolve(4004)
            }else{
                //对数组做一个乱序处理
                let arr = data.sort(()=>0.5 - Math.random())
                //console.log(arr)
                let arr2 = []
                arr.map(element=>{
                    //console.log(element)
                    arr2.push({
                        _id:element._id,
                        userName:element.listName,
                        headImg:element.headImg,
                        desc:element.author_desc
                    })
                })
               resolve(arr2)
        }
    })
}
)}
//导出
module.exports = authorsList